package com.fastgeek.platform.db.datasource;


import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

public class DataSourceMeta {

	private DataSource sqlds;

	private String name;

	private String dbType;

	public DataSourceMeta(String name, DataSource sqlds) {
		this.name = name;
		this.sqlds = sqlds;
		Connection conn = null;
		try {
			conn = sqlds.getConnection();
			dbType = conn.getMetaData().getDatabaseProductName();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
	}

	/**
	 * 
	 * @return Connection
	 * @throws SQLException 
	 */
	public Connection getConnection() throws SQLException {
		return this.sqlds.getConnection();
	}

	/**
	 * 
	 * @return String
	 */
	public String getDbType() {
		return this.dbType;
	}

	/**
	 * 
	 * @return String
	 */
	public String getName() {
		return this.name;
	}
}
